﻿package mortal.game.view.guild.cellrender
{
    import Message.Game.*;
    import com.gengine.utils.*;
    import com.mui.controls.*;
    import extend.language.*;
    import flash.events.*;
    import flash.text.*;
    import flash.utils.*;
    import mortal.common.*;
    import mortal.common.global.*;
    import mortal.common.tools.*;
    import mortal.game.events.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.resource.info.item.*;
    import mortal.game.utils.*;
    import mortal.game.view.common.*;
    import mortal.mvc.core.*;

    public class GuildWareHouseDealApplyListCellRenderer extends GuildCellRenderer
    {
        private var _txtDate:GTextFiled;
        private var _txtName:GTextFiled;
        private var _txtPosition:GTextFiled;
        private var _txtItemName:GTextFiled;
        private var _btnAgree:GButton;
        private var _btnRefuse:GButton;

        public function GuildWareHouseDealApplyListCellRenderer()
        {
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            var _loc_1:* = GlobalStyle.textFormatLv;
            _loc_1.align = TextFormatAlign.CENTER;
            this._txtDate = UIFactory.textField("12-25 16:45", 0, 5, 85, 22, this, _loc_1);
            _loc_1.color = GlobalStyle.colorBaiUint;
            this._txtName = UIFactory.textField("", 95, 5, 95, 22, this, _loc_1);
            this._txtPosition = UIFactory.textField("", 185, 5, 95, 22, this, _loc_1);
            this._txtItemName = UIFactory.textField("", 265, 5, 115, 22, this);
            this._btnAgree = UIFactory.gButton("" + Language.getString(71111), 390, 5, 42, 22, this);
            this._btnRefuse = UIFactory.gButton("" + Language.getString(71112), 435, 5, 42, 22, this);
            pushUIToDisposeVec(UIFactory.bg(0, 31, 480, 1, this, ImagesConst.SplitLine));
            this._btnAgree.configEventListener(MouseEvent.CLICK, this.onClickHandler);
            this._btnRefuse.configEventListener(MouseEvent.CLICK, this.onClickHandler);
            return;
        }// end function

        private function onClickHandler(event:MouseEvent) : void
        {
            var _loc_4:Dictionary = null;
            var _loc_2:* = this.data as SGuildWarehouseApply;
            var _loc_3:Object = {};
            _loc_3.toPlayerId = _loc_2.playerId;
            _loc_3.uid = _loc_2.uid;
            if (_loc_3.uid == 0)
            {
                _loc_4 = new Dictionary();
                _loc_4[_loc_2.unit] = _loc_2.amount;
                _loc_3.applyMoney = _loc_4;
            }
            else
            {
                _loc_3.applyMoney = new Dictionary();
            }
            switch(event.currentTarget)
            {
                case this._btnAgree:
                {
                    _loc_3.opr = true;
                    Dispatcher.dispatchEvent(new DataEvent(EventName.Guild_wareHouse_dealApplyList, _loc_3));
                    break;
                }
                case this._btnRefuse:
                {
                    _loc_3.opr = false;
                    Dispatcher.dispatchEvent(new DataEvent(EventName.Guild_wareHouse_dealApplyList, _loc_3));
                    break;
                }
                default:
                {
                    break;
                }
            }
            return;
        }// end function

        override public function get data() : Object
        {
            return super.data;
        }// end function

        override public function set data(param1:Object) : void
        {
            var _loc_2:SGuildWarehouseApply = null;
            super.data = param1;
            if (param1 is SGuildWarehouseApply)
            {
                _loc_2 = param1 as SGuildWarehouseApply;
                this._txtName.text = _loc_2.name;
                this._txtDate.text = DateParser.parse(_loc_2.applyDt, "MM-dd hh:mm");
                this._txtPosition.text = GameDefConfig.instance.getGuildPositonName(_loc_2.position);
                if (_loc_2.itemCode == 0)
                {
                    this._txtItemName.htmlText = "<p align = \'center\'>" + GameDefConfig.instance.getEPrictNameAddColoer(_loc_2.unit) + "*" + HTMLUtil.addColor(_loc_2.amount.toString(), GlobalStyle.colorBai) + "</p>";
                }
                else
                {
                    this._txtItemName.htmlText = "<p align = \'center\'>" + ItemsUtil.getItemName(new ItemData(_loc_2.itemCode)) + "*" + HTMLUtil.addColor(_loc_2.amount.toString(), GlobalStyle.colorBai) + "</p>";
                }
            }
            return;
        }// end function

    }
}
